<?php

namespace App\Http\Controllers\Backend;


use App\Manage\NewsManage;

class NewsController extends BaseController
{
    // 管理员管理
    public function initialize()
    {
        parent::initialize();

        $this->model = 'News';
    }

    // 设置突发新闻
    public function onTop()
    {
        $result = $this->onChangeNewsType('is_top');

        return $result;
    }

    // 设置标红新闻：重大新闻
    public function onMajor()
    {
        $result = $this->onChangeNewsType('is_major');

        return $result;
    }

    // 设置头条新闻
    public function onHeader()
    {
        $result = $this->onChangeNewsType('is_header');

        return $result;
    }


    // 突发，头条，标红
    public function onChangeNewsType($field)
    {
        $manage = new NewsManage();
        $result = $manage->onChangeNewsType($field);
        if($result === false){
            return $this->error($manage->getError());
        }

        return $this->success();
    }

}


